pushd ${SYSDIR}/sysroot
    rm usr/lib64/perl5/5.3x/site_perl/auto/XML/Parser/.packlist
    rm usr/lib64/perl5/5.3x/site_perl/auto/URI/.packlist
    rm usr/lib64/rustlib/install.log

    sed -i "s@${SYSDIR}/cross-tools/bin/perl@/usr/bin/perl@g" \
           $(file usr/bin/* | grep "Perl script text" | awk -F':' '{ print $1 }')
    sed -i "s@${SYSDIR}/cross-tools/bin/perl@/usr/bin/perl@g" \
           $(file usr/libexec/xscreensaver/* | grep "Perl script text" | awk -F':' '{ print $1 }')

    sed -i -e "s@${SYSDIR}/sysroot/lib@/usr/lib@g" \
           -e "s@${SYSDIR}/sysroot/usr@/usr@g" \
           -e "s@${SYSDIR}/sysroot@@g" \
           $(file usr/bin/*-config | grep ASCII | awk -F':' '{ print $1 }') \
           $(find usr/lib64/ -type f -name "*.sh") \
           $(find usr/lib64/pkgconfig/ -type f) \
           $(find usr/lib64/ -type f -name "*.cmake") \
           $(find usr/lib64/ -type f -name "Makefile*")
       
    sed -i -e "s@${SYSDIR}/sysroot@@g" \
           $(find usr/lib64/ -type f -name "*.py") \
           $(file usr/lib64/rustlib/* | grep ASCII | awk -F':' '{ print $1 }') \
           $(find usr/lib64/ -type f -name "*.prl") \
           $(find usr/lib64/ -type f -name "*.pri")

    sed -i -e "s@${SYSDIR}/cross-tools/bin/loongarch64-unknown-linux-gnu-@/usr/bin/@g" \
           $(file usr/bin/*-config | grep ASCII | awk -F':' '{ print $1 }')

    sed -i -e "s@${SYSDIR}/cross-tools/bin@/usr/bin@g" \
           $(grep -rl "cross-tools" $(file ${SYSDIR}/sysroot/usr/bin/* | grep ASCII | awk -F':' '{ print $1 }')) \
           $(grep -rl "cross-tools" $(file ${SYSDIR}/sysroot/usr/bin/* | grep text | awk -F':' '{ print $1 }')) \
           $(find usr/share/ -type f -name "*.pl")
popd

